﻿namespace NEvoWeb.Modules.NB_Store
{
    using DotNetNuke.Entities.Portals;
    using DotNetNuke.Entities.Users;
    using DotNetNuke.Services.Localization;
    using DotNetNuke.UI.UserControls;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections;
    using System.Runtime.CompilerServices;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Xml;

    public class GenXMLTemplate : ITemplate
    {
        protected string[] _aryTempl;
        protected bool _FoundEscapeChar;
        protected ArrayList _NestedLevel;
        protected UserInfo _UserInfo;

        public GenXMLTemplate(string TemplateText)
        {
            this._FoundEscapeChar = false;
            this._aryTempl = this.ParseTemplateText(TemplateText);
            this._NestedLevel = new ArrayList();
            this._NestedLevel.Add(true);
        }

        public GenXMLTemplate(string TemplateText, UserInfo UsrInfo)
        {
            this._FoundEscapeChar = false;
            this._UserInfo = UsrInfo;
            this._aryTempl = this.ParseTemplateText(TemplateText);
            this._NestedLevel = new ArrayList();
            this._NestedLevel.Add(true);
        }

        public GenXMLTemplate(string ResourceKey, string ResourceFile)
        {
            this._FoundEscapeChar = false;
            string templText = DotNetNuke.Services.Localization.Localization.GetString(ResourceKey, ResourceFile);
            if (templText == "")
            {
                templText = "---- NO TEMPLATE FOUND ---- [" + ResourceFile + "," + ResourceKey + "]";
            }
            this._aryTempl = this.ParseTemplateText(templText);
            this._NestedLevel = new ArrayList();
            this._NestedLevel.Add(true);
        }

        private void ChkB_DataBinding(object sender, EventArgs e)
        {
            CheckBoxList list = (CheckBoxList) sender;
            DataListItem namingContainer = (DataListItem) list.NamingContainer;
            try
            {
                IEnumerator enumerator;
                XmlNode node = this.getXMLnode(list.ID, "checkboxlist", Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "XMLData")));
                try
                {
                    enumerator = node.SelectNodes("./chk").GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        XmlNode current = (XmlNode) enumerator.Current;
                        string text = SharedFunctions.FormatFromSave(current.InnerText, TypeCode.String, "en-GB");
                        if (list.Items.FindByText(text).Value != null)
                        {
                            list.Items.FindByText(text).Selected = Conversions.ToBoolean(current.Attributes["value"].Value);
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
            list.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void ChkBox_DataBinding(object sender, EventArgs e)
        {
            CheckBox box = (CheckBox) sender;
            DataListItem namingContainer = (DataListItem) box.NamingContainer;
            try
            {
                box.Checked = Conversions.ToBoolean(this.getXMLvalue(box.ID, "checkbox", Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "XMLData"))));
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
            box.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void createCheckBox(Control container, XmlNode xmlNod)
        {
            CheckBox box = new CheckBox();
            box = (CheckBox) SharedFunctions.assignByReflection(box, xmlNod);
            box.DataBinding += new EventHandler(this.ChkBox_DataBinding);
            container.Controls.Add(box);
        }

        private void createCheckBoxList(Control container, XmlNode xmlNod)
        {
            CheckBoxList list = new CheckBoxList();
            bool flag = false;
            list = (CheckBoxList) SharedFunctions.assignByReflection(list, xmlNod);
            string innerXml = "";
            if (xmlNod.Attributes["datatype"] != null)
            {
                innerXml = xmlNod.Attributes["datatype"].InnerXml;
                list.Attributes.Add("datatype", innerXml);
            }
            if (xmlNod.Attributes["data"] != null)
            {
                string[] strArray2;
                if (xmlNod.Attributes["datavalue"] != null)
                {
                    strArray2 = xmlNod.Attributes["datavalue"].InnerXml.Split(new char[] { ';' });
                }
                else
                {
                    strArray2 = xmlNod.Attributes["data"].InnerXml.Split(new char[] { ';' });
                }
                string[] strArray = xmlNod.Attributes["data"].InnerXml.Split(new char[] { ';' });
                int upperBound = strArray.GetUpperBound(0);
                for (int i = 0; i <= upperBound; i++)
                {
                    ListItem item = new ListItem();
                    string str2 = innerXml.ToLower();
                    if (str2 == "double")
                    {
                        item.Text = SharedFunctions.FormatFromSave(strArray[i], TypeCode.Double, "en-GB");
                        item.Value = SharedFunctions.FormatFromSave(strArray2[i], TypeCode.Double, "en-GB");
                    }
                    else
                    {
                        item.Text = strArray[i];
                        item.Value = strArray2[i];
                    }
                    list.Items.Add(item);
                }
                if (xmlNod.Attributes["default"] != null)
                {
                    flag = Conversions.ToBoolean(xmlNod.Attributes["default"].InnerText);
                }
                if (flag)
                {
                    int num4 = list.Items.Count - 1;
                    for (int j = 0; j <= num4; j++)
                    {
                        list.Items[j].Selected = true;
                    }
                }
            }
            list.DataBinding += new EventHandler(this.ChkB_DataBinding);
            container.Controls.Add(list);
        }

        private void createDateEditControl(Control container, XmlNode xmlNod)
        {
            DateEditControl child = new DateEditControl();
            if (xmlNod.Attributes["id"] != null)
            {
                child.ID = xmlNod.Attributes["id"].InnerXml + "dctrl";
            }
            TextBox box = this.getcreateTextbox(container, xmlNod);
            box.Attributes.Add("datatype", "date");
            child.dateField = box;
            child.DataBinding += new EventHandler(this.Date_DataBinding);
            container.Controls.Add(child);
        }

        private void createDropDownList(Control container, XmlNode xmlNod)
        {
            DropDownList list = new DropDownList();
            list = (DropDownList) SharedFunctions.assignByReflection(list, xmlNod);
            string innerXml = "";
            if (xmlNod.Attributes["datatype"] != null)
            {
                innerXml = xmlNod.Attributes["datatype"].InnerXml;
                list.Attributes.Add("datatype", innerXml);
            }
            if (xmlNod.Attributes["databind"] != null)
            {
                list.Attributes.Add("databind", xmlNod.Attributes["databind"].InnerXml);
            }
            if (xmlNod.Attributes["data"] != null)
            {
                string[] strArray2;
                if (xmlNod.Attributes["datavalue"] != null)
                {
                    strArray2 = xmlNod.Attributes["datavalue"].InnerXml.Split(new char[] { ';' });
                }
                else
                {
                    strArray2 = xmlNod.Attributes["data"].InnerXml.Split(new char[] { ';' });
                }
                string[] strArray = xmlNod.Attributes["data"].InnerXml.Split(new char[] { ';' });
                int upperBound = strArray.GetUpperBound(0);
                for (int i = 0; i <= upperBound; i++)
                {
                    ListItem item = new ListItem();
                    string str2 = innerXml.ToLower();
                    if (str2 == "double")
                    {
                        item.Text = SharedFunctions.FormatFromSave(strArray[i], TypeCode.Double, "en-GB");
                        item.Value = SharedFunctions.FormatFromSave(strArray2[i], TypeCode.Double, "en-GB");
                    }
                    else
                    {
                        item.Text = strArray[i];
                        item.Value = strArray2[i];
                    }
                    list.Items.Add(item);
                }
            }
            list.DataBinding += new EventHandler(this.DDList_DataBinding);
            container.Controls.Add(list);
        }

        private void createLinkButton(Control container, XmlNode xmlNod)
        {
            LinkButton button = new LinkButton();
            button = (LinkButton) SharedFunctions.assignByReflection(button, xmlNod);
            if (xmlNod.Attributes["src"] != null)
            {
                button.Text = "<img src=\"" + xmlNod.Attributes["src"].InnerXml + "\" border=\"0\" />" + button.Text;
            }
            if ((xmlNod.Attributes["confirm"] != null) && (xmlNod.Attributes["confirm"].InnerXml != ""))
            {
                button.Attributes.Add("onClick", "javascript:return confirm('" + xmlNod.Attributes["confirm"].InnerXml + "');");
            }
            button.DataBinding += new EventHandler(this.LinkButton_DataBinding);
            container.Controls.Add(button);
        }

        private void createRadioButtonList(Control container, XmlNode xmlNod)
        {
            RadioButtonList list = new RadioButtonList();
            list = (RadioButtonList) SharedFunctions.assignByReflection(list, xmlNod);
            string innerXml = "";
            if (xmlNod.Attributes["datatype"] != null)
            {
                innerXml = xmlNod.Attributes["datatype"].InnerXml;
                list.Attributes.Add("datatype", innerXml);
            }
            if (xmlNod.Attributes["databind"] != null)
            {
                list.Attributes.Add("databind", xmlNod.Attributes["databind"].InnerXml);
            }
            if (xmlNod.Attributes["data"] != null)
            {
                string[] strArray2;
                if (xmlNod.Attributes["datavalue"] != null)
                {
                    strArray2 = xmlNod.Attributes["datavalue"].InnerXml.Split(new char[] { ';' });
                }
                else
                {
                    strArray2 = xmlNod.Attributes["data"].InnerXml.Split(new char[] { ';' });
                }
                string[] strArray = xmlNod.Attributes["data"].InnerXml.Split(new char[] { ';' });
                int upperBound = strArray.GetUpperBound(0);
                for (int i = 0; i <= upperBound; i++)
                {
                    ListItem item = new ListItem();
                    string str2 = innerXml.ToLower();
                    if (str2 == "double")
                    {
                        item.Text = SharedFunctions.FormatFromSave(strArray[i], TypeCode.Double, "en-GB");
                        item.Value = SharedFunctions.FormatFromSave(strArray2[i], TypeCode.Double, "en-GB");
                    }
                    else
                    {
                        item.Text = strArray[i];
                        item.Value = strArray2[i];
                    }
                    list.Items.Add(item);
                }
            }
            list.DataBinding += new EventHandler(this.RBL_DataBinding);
            container.Controls.Add(list);
        }

        private void createRangeValidator(Control container, XmlNode xmlNod)
        {
            RangeValidator validator = new RangeValidator {
                Text = "*"
            };
            validator = (RangeValidator) SharedFunctions.assignByReflection(validator, xmlNod);
            container.Controls.Add(validator);
        }

        private void createRegExValidator(Control container, XmlNode xmlNod)
        {
            RegularExpressionValidator validator = new RegularExpressionValidator {
                Text = "*"
            };
            validator = (RegularExpressionValidator) SharedFunctions.assignByReflection(validator, xmlNod);
            container.Controls.Add(validator);
        }

        private void createRequiredFieldValidator(Control container, XmlNode xmlNod)
        {
            RequiredFieldValidator validator = new RequiredFieldValidator {
                Text = "*"
            };
            validator = (RequiredFieldValidator) SharedFunctions.assignByReflection(validator, xmlNod);
            container.Controls.Add(validator);
        }

        private void createTextbox(Control container, XmlNode xmlNod)
        {
            TextBox child = this.getcreateTextbox(container, xmlNod);
            container.Controls.Add(child);
        }

        private void createTextEditor(Control container, XmlNode xmlNod)
        {
            GenTextEditor child = new GenTextEditor(xmlNod);
            if (xmlNod.Attributes["id"] != null)
            {
                child.ID = "gte" + xmlNod.Attributes["id"].InnerXml;
                if (xmlNod.Attributes["databind"] != null)
                {
                    child.Attributes.Add("databind", xmlNod.Attributes["databind"].InnerXml);
                }
                child.DataBinding += new EventHandler(this.TextEditor_DataBinding);
                container.Controls.Add(child);
            }
        }

        private void createValidationSummary(Control container, XmlNode xmlNod)
        {
            ValidationSummary summary = new ValidationSummary();
            summary = (ValidationSummary) SharedFunctions.assignByReflection(summary, xmlNod);
            container.Controls.Add(summary);
        }

        private void Date_DataBinding(object sender, EventArgs e)
        {
            DateEditControl control = (DateEditControl) sender;
            DataListItem namingContainer = (DataListItem) control.NamingContainer;
            try
            {
                control.dateField.Text = this.getXMLvalue(control.ID.Substring(0, control.ID.Length - 5), "textbox", Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "XMLData")));
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
            control.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void DDList_DataBinding(object sender, EventArgs e)
        {
            DropDownList list = (DropDownList) sender;
            DataListItem namingContainer = (DataListItem) list.NamingContainer;
            try
            {
                string str = this.getXMLvalue(list.ID, "dropdownlist", Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "XMLData")));
                if (list.Items.FindByValue(str) != null)
                {
                    list.SelectedValue = str;
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
            list.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void General_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            try
            {
                literal.Text = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), literal.Text));
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private TextBox getcreateTextbox(Control container, XmlNode xmlNod)
        {
            TextBox box2 = new TextBox {
                Text = ""
            };
            box2 = (TextBox) SharedFunctions.assignByReflection(box2, xmlNod);
            if (xmlNod.Attributes["datatype"] != null)
            {
                box2.Attributes.Add("datatype", xmlNod.Attributes["datatype"].InnerXml);
            }
            if (xmlNod.Attributes["databind"] != null)
            {
                box2.Attributes.Add("databind", xmlNod.Attributes["databind"].InnerXml);
            }
            box2.DataBinding += new EventHandler(this.Text_DataBinding);
            return box2;
        }

        private XmlNode getXMLnode(string DataXML, string XPath)
        {
            return SharedFunctions.getGenXMLnode(DataXML, XPath);
        }

        private XmlNode getXMLnode(string ctrlID, string CtrlType, string DataXML)
        {
            if (((ctrlID == null) | (CtrlType == null)) | (DataXML == null))
            {
                return null;
            }
            return SharedFunctions.getGenXMLnode(DataXML, "genxml/" + CtrlType + "/" + ctrlID.ToLower());
        }

        private string getXMLvalue(string DataXML, string XPath)
        {
            return SharedFunctions.getGenXMLvalue(DataXML, XPath);
        }

        private string getXMLvalue(string ctrlID, string CtrlType, string DataXML)
        {
            return SharedFunctions.getGenXMLvalue(DataXML, "genxml/" + CtrlType + "/" + ctrlID.ToLower());
        }

        public void InstantiateIn(Control container)
        {
            string xml = "";
            XmlDocument document = new XmlDocument();
            string str = "";
            int upperBound = this._aryTempl.GetUpperBound(0);
            for (int i = 0; i <= upperBound; i++)
            {
                Literal literal;
                if (HttpUtility.HtmlDecode(this._aryTempl[i]).ToLower().StartsWith("<tag"))
                {
                    xml = HttpUtility.HtmlDecode(this._aryTempl[i]);
                    xml = "<root>" + xml + "</root>";
                    document.LoadXml(xml);
                    XmlNode xmlNod = document.SelectSingleNode("root/tag");
                    if (xmlNod.Attributes["type"] != null)
                    {
                        str = xmlNod.Attributes["type"].InnerXml.ToLower();
                    }
                    if (xmlNod.Attributes["ctrltype"] != null)
                    {
                        str = xmlNod.Attributes["ctrltype"].InnerXml.ToLower();
                    }
                    if (str != "")
                    {
                        string str3 = str;
                        switch (str3)
                        {
                            case "linkbutton":
                                this.createLinkButton(container, xmlNod);
                                break;

                            case "textbox":
                                this.createTextbox(container, xmlNod);
                                break;

                            case "dateeditcontrol":
                                this.createDateEditControl(container, xmlNod);
                                break;

                            case "dropdownlist":
                                this.createDropDownList(container, xmlNod);
                                break;

                            case "checkbox":
                                this.createCheckBox(container, xmlNod);
                                break;

                            case "radiobuttonlist":
                                this.createRadioButtonList(container, xmlNod);
                                break;

                            case "checkboxlist":
                                this.createCheckBoxList(container, xmlNod);
                                break;

                            case "rvalidator":
                                this.createRangeValidator(container, xmlNod);
                                break;

                            case "rfvalidator":
                                this.createRequiredFieldValidator(container, xmlNod);
                                break;

                            case "revalidator":
                                this.createRegExValidator(container, xmlNod);
                                break;

                            case "validationsummary":
                                this.createValidationSummary(container, xmlNod);
                                break;

                            default:
                                if (str3 == "dnntexteditor")
                                {
                                    this.createTextEditor(container, xmlNod);
                                }
                                else
                                {
                                    if (this._FoundEscapeChar)
                                    {
                                        this._aryTempl[i] = Strings.Replace(this._aryTempl[i], "**SQROPEN**", "[", 1, -1, CompareMethod.Binary);
                                        this._aryTempl[i] = Strings.Replace(this._aryTempl[i], "**SQRCLOSE**", "]", 1, -1, CompareMethod.Binary);
                                    }
                                    literal = new Literal {
                                        Text = xml
                                    };
                                    literal.DataBinding += new EventHandler(this.General_DataBinding);
                                    container.Controls.Add(literal);
                                }
                                break;
                        }
                    }
                }
                else if (this._aryTempl[i].ToUpper() == "TAG:END")
                {
                    literal = new Literal {
                        Text = ""
                    };
                    literal.DataBinding += new EventHandler(this.Visible_DataBinding);
                    container.Controls.Add(literal);
                }
                else if (this._aryTempl[i].ToUpper().StartsWith("TAG:TEST"))
                {
                    string[] strArray = this._aryTempl[i].Split(new char[] { ':' });
                    literal = new Literal {
                        Text = strArray[2]
                    };
                    literal.DataBinding += new EventHandler(this.TokenTest_DataBinding);
                    container.Controls.Add(literal);
                }
                else
                {
                    if (this._FoundEscapeChar)
                    {
                        this._aryTempl[i] = Strings.Replace(this._aryTempl[i], "**SQROPEN**", "[", 1, -1, CompareMethod.Binary);
                        this._aryTempl[i] = Strings.Replace(this._aryTempl[i], "**SQRCLOSE**", "]", 1, -1, CompareMethod.Binary);
                    }
                    literal = new Literal {
                        Text = this._aryTempl[i]
                    };
                    container.Controls.Add(literal);
                }
            }
        }

        private void LinkButton_DataBinding(object sender, EventArgs e)
        {
            LinkButton button = (LinkButton) sender;
            DataListItem namingContainer = (DataListItem) button.NamingContainer;
            try
            {
                if (DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), button.CommandArgument) != null)
                {
                    button.CommandArgument = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), button.CommandArgument));
                }
                else
                {
                    XmlNode node = null;
                    node = this.getXMLnode(button.ID, button.Text, Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "XMLData")));
                    if (node != null)
                    {
                        button.CommandArgument = node.InnerXml;
                    }
                    else
                    {
                        node = this.getXMLnode(Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "XMLData")), button.Text);
                        if (node != null)
                        {
                            button.CommandArgument = node.InnerXml;
                        }
                        else
                        {
                            button.CommandArgument = "";
                        }
                    }
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
        }

        private string[] ParseTemplateText(string TemplText)
        {
            char[] separator = new char[] { '[', ']' };
            this._FoundEscapeChar = false;
            if ((Strings.InStr(TemplText, "[[", CompareMethod.Binary) > 0) | (Strings.InStr(TemplText, "]]", CompareMethod.Binary) > 0))
            {
                TemplText = Strings.Replace(TemplText, "[[", "**SQROPEN**", 1, -1, CompareMethod.Binary);
                TemplText = Strings.Replace(TemplText, "]]", "**SQRCLOSE**", 1, -1, CompareMethod.Binary);
                this._FoundEscapeChar = true;
            }
            return TemplText.Split(separator);
        }

        private void RBL_DataBinding(object sender, EventArgs e)
        {
            RadioButtonList list = (RadioButtonList) sender;
            DataListItem namingContainer = (DataListItem) list.NamingContainer;
            try
            {
                string str = this.getXMLvalue(list.ID, "radiobuttonlist", Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "XMLData")));
                if (list.Items.FindByValue(str) != null)
                {
                    list.SelectedValue = str;
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
            list.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void Text_DataBinding(object sender, EventArgs e)
        {
            TextBox box = (TextBox) sender;
            DataListItem namingContainer = (DataListItem) box.NamingContainer;
            try
            {
                if (box.Attributes["databind"] != null)
                {
                    box.Text = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), box.Attributes["databind"]));
                }
                else
                {
                    box.Text = this.getXMLvalue(box.ID, "textbox", Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "XMLData")));
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
            box.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void TextEditor_DataBinding(object sender, EventArgs e)
        {
            GenTextEditor editor = (GenTextEditor) sender;
            TextEditor editor2 = (TextEditor) editor.Controls[0];
            DataListItem namingContainer = (DataListItem) editor.NamingContainer;
            try
            {
                if (editor.Attributes["databind"] != null)
                {
                    editor2.Text = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), editor.Attributes["databind"]));
                }
                else
                {
                    editor2.Text = this.getXMLvalue(editor2.ID, "edt", Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "XMLData")));
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
        }

        private void TokenTest_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            TokenTest test = new TokenTest();
            SharedFunctions.assignByReflection(test, literal.Text);
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            bool flag = true;
            if (this._UserInfo != null)
            {
                flag = test.getVisibleMode(currentPortalSettings.PortalId, -1, namingContainer, this._UserInfo, Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]));
            }
            literal.Visible = false;
            this._NestedLevel.Add(flag);
        }

        private void Visible_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            literal.Visible = false;
            if (this._NestedLevel.Count > 0)
            {
                this._NestedLevel.RemoveAt(this._NestedLevel.Count - 1);
            }
        }
    }
}

